const fs = require('fs')

function p1 () {
    return new Promise((resolve, reject) => {
        fs.readFile('./1.txt', 'utf8', (err, data) => {
            if(err) {
                reject(err)
            }else {
                resolve(data)
            }
        })
    })
}
function p2 () {
    return new Promise((resolve, reject) => {
        fs.readFile('./2.txt', 'utf8', (err, data) => {
            if(err) {
                reject(err)
            }else {
                resolve(data)
            }
        })
    })
}
function p3 () {
    return new Promise((resolve, reject) => {
        fs.readFile('./3.txt', 'utf8', (err, data) => {
            if(err) {
                reject(err)
            }else {
                resolve(data)
            }
        })
    })
}

p1().then(result => {
    console.log(result)
    return p2()
}).then(result => {
    console.log(result)
    return p3()
}) .then(result => {
    console.log(result)
}).catch(err => {
    console.log(err)
})
